const gIf = require('gulp-if');
const gulp = require('gulp');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const minimist = require('minimist');

/**
 * 命令行参数
 * @type {[type]}
 */
const options = minimist(process.argv.slice(2) ,{
  boolean: ['development'] ,
  default: {
    development: process.env.NODE_ENV === 'development'
  }
});

gulp.task('scripts' ,function (){
  return gulp.src('src/pagination.module.js')
    .pipe(babel({
      presets: ['es2015']
    }))
    .pipe(gIf(!options.development ,uglify()))
    .pipe(gIf(!options.development ,rename('pagination.module.min.js')))
    .pipe(gulp.dest('dist'));
});

gulp.task('default' ,['scripts']);
